package com.da.javatest.leetCode;

import java.util.Arrays;
import java.util.Comparator;

/**
 * @author chenlida
 * @date 2019/1/18 10:34
 * @description
 */
public class Code646 {
    public int findLongestChain(int[][] pairs) {
        int total = 1;
        Arrays.sort(pairs, Comparator.comparingInt(x -> x[1]));
        int s = pairs[0][1];
        for (int i = 1; i < pairs.length; i++) {
            if (s < pairs[i][0]) {
                total += 1;
                s = pairs[i][1];
            }
        }
        return total;
    }
}
